from sqlalchemy import Column
from sqlalchemy import Integer
from sqlalchemy import Unicode

from sqlalchemy.exc import IntegrityError
from sqlalchemy.ext.declarative import declarative_base

from sqlalchemy.orm import scoped_session
from sqlalchemy.orm import sessionmaker

from zope.sqlalchemy import ZopeTransactionExtension

from sqlalchemy import Text


from scp.modelo.models import Base

__all__ = [ 'Atributo' ]


from sqlalchemy import Table, Column, Integer, ForeignKey
from sqlalchemy.orm import relationship, backref





"""association_table = Table('atributo_tipo_dato', Base.metadata,
    Column('atributo_id', Integer, ForeignKey('atributo.id')),
    Column('tipo_dato_id', Integer, ForeignKey('permiso.id'))
)"""


class Atributo(Base):
    """ The SQLAlchemy declarative model class for a Page object. """
    __tablename__ = 'tipo_atributo'
    id = Column(Integer, primary_key=True)
    nombre = Column(Unicode(50), nullable=False, unique=True)
    tipo_dato = Column(Unicode(20), nullable=False)
    observacion = Column(Unicode(50), nullable=False)
    tipo_dato_id = Column(Integer, ForeignKey('tipo_dato.id'))
    dato = relationship("Tipo_Dato", backref=backref("tipo_atributo", uselist=False))

